package com.spring.demo1;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestIOC {
	public static void main(String[] args) {

		//1.加载spring配置文件，根据配置创建对象
		ApplicationContext context = (ApplicationContext) new ClassPathXmlApplicationContext("config.xml");
		//2.得到配置创建的对象
		User user=(User) context.getBean("user");//强转，引号内为配置文件中的id名
		User user1=(User) context.getBean("user");
		System.out.println(user);//单实例输出地址
		System.out.println(user1);//多实例输出地址不一样
		user.add();//方法调用
	}
}
